package com.levy.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.Method;

@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.METHOD, ElementType.TYPE }) //use mutiple target type
@Inherited
public @interface MyAnnotation {
	public String myName() default ""; 
	public Class proxyClass() default String.class; //Use default value
	public String[] value() default {};     //constructor method, we could use it without name  @MyAnnotation({ "111" })
	
}



class AnnotationTest {

	@MyAnnotation(myName = "", value = { "111" })
	public void test1() {
	}

	@MyAnnotation(myName = "")
	public void test2() {
	}

	@MyAnnotation({ "111" })
	public void test3() {
	}
}

class Test{
	
	public void main() throws SecurityException, NoSuchMethodException{
		Method method = AnnotationTest.class.getMethod("test1", null);   //取得被注释的方法,AnnotationTest.class为该方法所在的类     
		MyAnnotation mr = method.getAnnotation(MyAnnotation.class); //取得注释对象     
		String[] value = mr.value();    //取得value的值,对应Bean的get方法.    
	}
	
}